import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
const routes = [
    // 注册
    {
        path: '/login',
        name: 'login',
        component: () => import('./view/login/login')
    },
    {
        path: '/Register',
        name: 'Register',
        component: () => import('./view/login/register')
    },
    {
        path: '/setpass',
        name: 'setpass',
        component: () => import('./view/login/setpass')
    },
	{
	    path: '/setpasspay',
	    name: 'setpasspay',
	    component: () => import('./view/login/setpasspay')
	},
	{
	    path: '/registerpage',
	    name: 'registerpage',
	    component: () => import('./view/login/registerpage')
	},
	
    {
        path: '/',
        redirect: '/mall',
        component: () => import('./view/Main'),
        children: [
            {
                path: '/mall',
                name: 'mall',
                component: () => import('./view/mall/index')
            },
            {
                path: '/guide',
			    name: 'Guide',
			    component: () => import('./view/home/guide')
            },
            {
                path: '/coinTread',
                name: 'CoinTread',
                component: () => import('./view/home/coinTread')
            },
			{
			    path: '/onLine',
			    name: 'OnLine',
			    component: () => import('./view/personal/onLine')
			},
            {
                path: 'personal',
                name: 'personal',
                component: () => import('./view/personal/index')
            },
			{
			    path: 'graborder',
			    name: 'graborder',
			    component: () => import('./view/article/graborder')
			},
        ]
    },
	{
	    path: 'graborderDetail',
	    name: 'graborderDetail',
	    component: () => import('./view/article/graborderDetail')
	},
    {
        path: '/address',
        name: 'address',
        component: () => import('./view/personal/address')
    },
	{
	    path: '/bindcard',
	    name: 'bindcard',
	    component: () => import('./view/personal/bindcard')
	},
    {
        path: '/clocklistxx',
        name: 'clocklistxx',
        component: () => import('./view/home/clocklistxx')
    }, 
    {
        path: '/coinTread',
        name: 'CoinTread',
        component: () => import('./view/home/coinTread')
    },
    {
        path: '/coinDetails',
        name: 'CoinDetails',
        component: () => import('./view/home/coinDetails')
    },
    {
        path: '/changeuser',
        name: 'changeuser',
        component: () => import('./view/personal/changeuser')
    },
    
    {
        path: '/newdeatil',
        name: 'newdeatil',
        component: () => import('./view/home/newdeatil')
    },

    {
        path: '/noticeList',
        name: 'NoticeList',
        component: () => import('./view/home/noticeList')
    },
    {
        path: '/noticeDetails',
        name: 'NoticeDetails',
        component: () => import('./view/home/noticeDetails')
    },
    {
        path: '/pdraw',
        name: 'pdraw',
        component: () => import('./view/personal/pdraw')
    },
    {
        path: '/rechargeList',
        name: 'rechargeList',
        component: () => import('./view/personal/rechargeList')
    },
    {
        path: '/withdraw',
        name: 'withdraw',
        component: () => import('./view/personal/withdraw')
    },
    {
        path: '/pdrawTrx',
        name: 'pdrawTrx',
        component: () => import('./view/personal/pdrawTrx')
    },
    {
        path: '/pdrawUsdt',
        name: 'pdrawUsdt',
        component: () => import('./view/personal/pdrawUsdt')
    },
    {
        path: '/pdrawChange',
        name: 'pdrawChange',
        component: () => import('./view/personal/pdrawChange')
    },
    {
        path: '/withdrawRecord',
        name: 'WithdrawRecord',
        component: () => import('./view/personal/withdrawRecord')
    },
    {
        path: '/recharge',
        name: 'Recharge',
        component: () => import('./view/personal/recharge')
    },
    {
        path: '/rechargeList',
        name: 'RechargeList',
        component: () => import('./view/personal/rechargeList')
    },
    {
        path: '/income',
        name: 'Income',
        component: () => import('./view/personal/income')
    },
    {
        path: '/incomet',
        name: 'incomet',
        component: () => import('./view/personal/incomet')
    },
    {
        path: '/team',
        name: 'Team',
        component: () => import('./view/personal/team')
    },
    {
        path: '/myteam',
        name: 'myteam',
        component: () => import('./view/personal/myteam')
    },
    {
        path: '/messagelist',
        name: 'messagelist',
        component: () => import('./view/mall/messagelist')
    },
    {
        path: '/message',
        name: 'Message',
        component: () => import('./view/personal/message')
    },
];

const router = new Router({
    routes
});

// const whiteList = ['/forgetPsd', '/sharereg']

// router.beforeEach((to, from, next) => {
//     if (to.path == '/') {
//         if (localStorage.getItem('usertoken')) {
//             next('/');
//         } else {
//             next();
//         }
//     } else {
//         if (whiteList.indexOf(to.path) < 0 && !localStorage.getItem('usertoken')) {
//             next('/');
//         } else {
//             next();
//         }
//     }
// })
router.afterEach((to, from, next) => {
    window.scrollTo(0, 0);
})
export {
    router
};